package web.interceptor;

import javax.servlet.http.HttpSession;
import java.lang.Long;
import org.springframework.web.servlet.HandlerInterceptor;

public class CoreInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(javax.servlet.http.HttpServletRequest request,
            javax.servlet.http.HttpServletResponse response, Object handler) throws Exception {
        HttpSession session = request.getSession();
        Long id = (Long) session.getAttribute("UID");

        if (id == null) {
            response.sendRedirect("/login");
            return false;
        }

        return true;
    }
}
